<?php
/**
 * @author renakeji@163.com
 * @date 2020/5/23
 */
namespace App\Exceptions;

use Throwable;

class getParamException extends \Exception
{
    const ERROR_CODE = -100;
    const ERROR_MSG = 'jsonException';

    private $data =[];

    public function __construct($message = "", $code = 0, $data = [])
    {
        $this->code = $code  ? : self::ERROR_CODE;
        $this->message  = $message ? : self::ERROR_MSG;
        $this->data = $data;
    }

    public function getData()
    {
        return $this->data;
    }

    /**
     * 异常输出
     */
    public function render($request)
    {
        return response()->json([
            'data' => $this->getData(),
            'code' => $this->getCode(),
            'messgae' => $this->getMessage(),
        ], 200);
    }
}
